package com.tamtamy.jtta.data.json;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.tamtamy.jtta.data.NoticeList;
import com.tamtamy.jtta.exception.NoResultException;

public class JSONNoticeList extends NoticeList{
	
	private static final long serialVersionUID = -4354126415771653419L;

	public JSONNoticeList(JSONObject jsonObject) throws NoResultException{
		super();
		JSONArray noticeListJSON = (JSONArray)jsonObject.get("list");
		if (noticeListJSON == null || noticeListJSON.size()==0){
			throw new NoResultException("No comments found");
		}
		for (int i = 0; i < noticeListJSON.size(); i++) {
			JSONObject noticeJSON = noticeListJSON.getJSONObject(i);
			this.add(new JSONNotice(noticeJSON));
		}	
	}
}
